#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time,threading
blance = 0
lock = threading.Lock()
def change_it(n):
    global blance
    blance = blance + n
    blance = blance - n
def run_thread(arg):
    for value in range(100):
        print('value=',value)
        lock.acquire()
        try:
            change_it(arg)
        finally:
            lock.release()
t1 = threading.Thread(target = run_thread,args=(5,))
t2 = threading.Thread(target = run_thread,args=(8,))
t1.start()
t2.start()
t1.join()
t2.join()
print('blance=',blance)
